<?xml version="1.0" standalone="yes" ?><script uid="{F1ADCA9A-1232-44F0-AEE9-A284C42D8289}" shared="f" desc="Virus Alert" help="This applet checks all incoming mail messages for executable attachments, which are the common delivery mechanism for viruses and worms.  This applet is not a substitute for a dedicated virus scanning application." imglib="groupwise.dli" imgid="175" fav="f" inten="t" vbe="f" created="20010605T172520" smod="20020730T131007" pmod="20011118T151039" lfdn="" rm="t" ver="" author="" amail="" aurl="" acom="" aphone="" comex="f" dxwrn="f"><integrations><integration type="ngw_event" context="GW.CLIENT" event="GW#E#0" seq="a" otherid="" menu="" before="" anchor="an_under"></integration><integration type="ngw_event" context="GW.CLIENT" event="GW#E#1" seq="a" otherid="" menu="" before="" anchor="an_under"></integration></integrations><source><primary><![CDATA['''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Formativ Business Solution Pack
' Virus Alert Applet
' Version 1.0
'
' This applet checks all incoming mail messages for executable attachments.  The
' most common viruses and worms are sent via message attachments and, in many
' cases, the user is not aware of the potential danger arising from opening the
' attachments.  This applet is not a virus scanner: it checks for attachments which
' are _capable_ of launching a virus.  By alerting the user to potential danger,
' this applet provides another level of protection against destructive attacks.
' 
' The applet checks the message attachment and deletes suspicious messages (storing 
' them in the trash can).  When the applet runs for the first time it will check
' all received mailbox messages and from then onwards it will only check new
' incoming mail.
'
' The Virus Alert applet currently checks the following file extensions:  
' exe, com, vbe, vbs, pif, mtx, scr, bat.  This applet does not check for DOC or
' XLS files, which can potentially contain applet viruses.  By modifying this
' applet you can extend the file extension check for these type of files if desired.
'
' NOTE: This applet is not a substitute for a virus scanning program. It helps to
' quickly identify attachments which are capable of carrying viruses or worms and a
' virus checking application should then be used to scan the attachment for viruses.
' If you don't have a GroupWise integrated virus scanner, then you should save the
' attachment to disk, preferably in a separate folder (perhaps called Virus Check)
' and scan the attachment before opening it.
' 
'
' INTEGRATIONS: This applet requires integration with GroupWise message arrival.
' GroupWise Application - Events - On Message Arrival
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'-->Flexalock

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' History
'
' 24 July - JCS: Text modification
'
' 31 July 01- MA: If any suspicious mails are found then send an alert email
' to the user and add the suspicious mail's subject, sender name, body text into
' a new mail and delete the suspicious mail.
'
' 15 October 01 - MA: Messages Read value restore and refresh the mailbox.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Global variables
dim Msg
dim HRT
dim FSO
dim iCount
dim FILENAME
dim StringList
dim MailBoxObj
dim NewMsgObj
dim NewMailCount
dim AttachmentName

DEFAULTFOLDER = Utilities.GetDataDirectory

const CAPTION = "Formativ Business Solutions"
HLine = "____________________________________________________________________________"


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Mainline processing
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Main(Client, GWEvent)
 
  dim StatusDlg
  dim sFilter
  HRT = Chr(13) & Chr(10)

  FILENAME = DEFAULTFOLDER&"ADV_CheckOnce.ol"
  set StringList = Utilities.StringList
  set FSO = CreateObject("Scripting.FileSystemObject")    

  
  'Setup all common virus file ext
  CommonVirusFiles  

  ' Check all messages first and create a file. If file exists then only check the 
  ' incoming messages. 
  
  if FSO.FileExists(FILENAME) then
    CheckNewMessages
  else  
    sFilter = ("(MAIL)AND(BOX_TYPE = INCOMING)")
    Set MailBoxObj = GroupWise.Account.MailBox.FindMessages(sFilter)
    iCount = MailBoxObj.Count  
    if (iCount > 1) then    
      CheckAllInboxMessages    
    end if    
    set MailBoxObj = nothing
  end if
  
  ' Cleanup all object we created in startup
  set FSO = nothing
  set StringList = nothing
  
end sub


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Common virus susceptible attachments. Please use StringList.Add("File extension") 
' to add a new file extension in the list.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub CommonVirusFiles

 StringList.Add(".exe")  
 StringList.Add(".com")  
 StringList.Add(".bat")  
 StringList.Add(".vbe") 
 StringList.Add(".vbs")   
 StringList.Add(".pif")  
 StringList.Add(".mtx")  
 StringList.Add(".scr")
 StringList.Add(".x-wav")
 'uncomment the following lines if you want the applet to warn you about DOC and XLS files  
' StringList.Add(".doc")  
' StringList.Add(".xls")  
 
end sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Check all inbox messages.
' This function will run once only. Next time only received mail will check.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub CheckAllInboxMessages
    
    dim ReadVal    
    dim MailFound  
     
    On Error Resume Next             
    Set StatusDlg = Utilities.NewStatusDialog    
    StatusDlg.ProgressRange = iCount
    StatusDlg.Title = CAPTION
    StatusDlg.CanCancel = TRUE
    StatusDlg.Show
    
    ' set each message object
    for x = 1 to iCount 
      set Msg = MailBoxObj.Item(x)
      'Store read property
      ReadVal = Msg.Read
      
      ' Check mail for the suspicious attachments
      if VirusCheck = TRUE then
        SendAlertMail    
        MailFound = MailFound + 1
      end if        

      StatusDlg.ProgressPosition = x 
      StatusDlg.MainText = "Mails checked: "&x   
      if MailFound > 0 then 
        StatusDlg.StatusText = "Sender: "&Msg.Sender.DisplayName&HRT&"Suspicious messages found: "&MailFound
      else
        StatusDlg.StatusText = "Sender: "&Msg.Sender.DisplayName       
      end if
                 
      ' Quit whole process if user select to exit
      if StatusDlg.Cancel then
        StatusDlg.Hide
        exit sub
      end if
      
      'Set the read property
      Msg.Read = ReadVal
            
      set Msg = nothing
    next

    ' create the file so we don't check all message next time.
    dim TextStream
    set TextStream = FSO.CreateTextFile(FILENAME)
    TextStream.Write("Created by  - Advansys Formativ Virus Alert applet. Date: "&now)  
    TextStream.Close
    set TextStream = nothing
       
    StatusDlg.Hide        
    set Msg = nothing
    set StatusDlg = nothing   
    
    GroupWise.Account.MailBox.Refresh

end sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Send a alert mail to the user
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub SendAlertMail
  
  dim MsgBody
  dim NewMsg
  Set NewMsg = GroupWise.Account.MailBox.Messages.Add(4)
  MsgRecipient = NewMsg.Recipients.Add(GroupWise.Account.Owner.EmailAddress,,0) 
  AddrTo = GroupWise.Account.Owner.DisplayName  
  if Msg.Sender.EmailAddress<> "" then
    SenderEmail = Msg.Sender.EmailAddress
  else 
    SenderEmail = Msg.Sender.DisplayName
  end if  
  MsgBody = "Dear "&AddrTo&","& HRT & HRT &"Formativ Virus Alert applet found the following message, which has one or more attachments which may be capable of delivering a virus.  The suspicious message has been removed from the Mailbox and placed in the Trash can (recoverable).  We recommend that you do not open the attachment(s) until you have used a virus scanning program to ensure the attachments are safe."&HRT&HRT&"Thanks"&HRT&CAPTION&HRT&HLine&HRT&"Sender name: "&Msg.Sender.DisplayName&HRT&"Email Address: "&SenderEmail&HRT&"Subject: "&Msg.Subject&HRT&"Attachment: "&AttachmentName&HRT&"Date and Time received: "&Msg.CreationDate&HRT&HRT&Msg.BodyText&HRT&HLine&HRT                   
  NewMsg.FromText = "Formativ Virus Alert applet"
  NewMsg.Subject =  "Suspect message attachment found"     
  NewMsg.BodyText.PlainText = MsgBody
  NewMsg.Priority = 3  
  Set objEmail = NewMsg.Send
  
  ' Delete current mail
  Msg.delete  
  
  set NewMsg = nothing
  AttachmentName = ""
  
end sub


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Check only new mails
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function CheckNewMessages
  
  dim sFilter

  sFilter = ("(MAIL)AND(BOX_TYPE = INCOMING)AND(NOT READ)")

  On Error Resume Next
  Set NewMsgObj = GroupWise.Account.MailBox.FindMessages(sFilter)
  NewMailCount = NewMsgObj.Count
  
  if  NewMailCount> 0 then
    CheckAttachments  
  end if
  
  
  set NewMsgObj = nothing
  
  GroupWise.Account.MailBox.Refresh
  
end function
  

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Check new mail attachments
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function CheckAttachments

  dim ReadVal
  
  for x = 1 to NewMailCount
    set Msg = NewMsgObj.Item(x)
    'Store read property    
    ReadVal = Msg.Read
    
    if VirusCheck = TRUE then      
      SendAlertMail         
    end if

    Msg.Read = ReadVal
    
    set Msg = nothing           
  next 
       
end function


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This function will check all attachments with common virus file extension
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function VirusCheck

  dim AttachCount
  dim AttachEntry  
  If Msg.Attachments.count > 0 then
    for AttachCount = 1 to Msg.Attachments.count  
      set AttachEntry = Msg.Attachments.Item(AttachCount)
        for x = 0 to (StringList.Count -1)
          if (Instr(1, LCase(AttachEntry.FileName), LCase(StringList.Strings(x)))) <> 0  then
            AttachmentName = AttachmentName&AttachEntry.FileName&", "
            ItemFound = ItemFound + 1
            VirusCheck = TRUE
          end if
        next
      set AttachEntry = nothing
    next  
  End if
  
end function
]]></primary><backup/></source></script>